<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
        <meta name="author" content="order by dede58.com"/>
		<title>会员登录</title>
		<link rel="stylesheet" type="text/css" href="./css/login.css">
		
	</head>
	<body>
		<!-- login -->
		<div class="top center">
			<div class="logo center">
				<a href="./index.html" target="_blank"><img src="./image/mistore_logo.png" alt=""></a>
			</div>
		</div>
		<form  method="post" action="login.jsp" class="form center">
		<div class="login">
			<div class="login_center">
				<div class="login_top">
					<div class="left fl">会员登录</div>
					<div class="right fr">您还不是我们的会员？<a href="./register.jsp" target="_self">立即注册</a></div>
					<div class="clear"></div>
					<div class="xian center"></div>
				</div>
				<div class="login_main center">
					<div class="username">用户名:&nbsp;<input class="shurukuang" type="text" name="username" placeholder="请输入你的用户名" id="uname"/></div>
					<div class="username">密&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;<input class="shurukuang" type="password" name="password" id="pwd" placeholder="请输入你的密码"/></div>
					<div class="username" style="text-align:center; color:red;" id="errorinfo">
						<div class="clear"></div>
					</div>
				</div>
				<div class="login_submit">
					<input class="submit" type="button" name="button" onclick="login()" value="立即登录" >
				</div>
				
			</div>
		</div>
		</form>
		<footer>
			<div class="copyright">简体 | 繁体 | English | 常见问题</div>
			<div class="copyright">小米公司版权所有-京ICP备10046444-<img src="./image/ghs.png" alt="">京公网安备11010802020134号-京ICP证110507号</div>
			
			<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
		<script>
		
		var url=location.href;
		//判断是直接进入登录界面，还是通过注册进入的登录界面
		if(  url.split("?").length>1  ){
			$("#uname").val( url.split("?")[1].split("=")[1] );
		}
		
		function login(){
			var uname=$("#uname").val();
			var pwd=$("#pwd").val();
			
			var url=location.href;
			//判断是直接进入登录界面，还是通过注册进入的登录界面
			if(  url.split("?").length>1  ){
				$("#uname").val( url.split("?")[1].split("=")[1] );
			}
			
			if(uname==null || uname==""){
				$("#errorinfo").html("用户名不能为空");
			}else if(pwd==null || pwd=="" ){
				$("#errorinfo").html("密码不能为空");
			}else if(uname!=null || uname=="" || pwd!=null || pwd!=""  ){
				  //发送ajax请求
	              $.post("userServlet",{
	            	op:'login',
	            	uname:uname,
	            	pwd:pwd
	              },function(data){
	            	  if(data>0 ){
	            		  $("#errorinfo").html("登录成功，即将跳转主界面....."); 
	            		  //延时器
	            		  setTimeout(function(){
	            			  location.href="index.jsp";
	            		  },1500);
	            	  }else{
	            		$("#errorinfo").html("登录失败，用户名或密码错误....."); 
	            	  }
	              },"text");
			}
			

		};
		</script>

		</footer>
	</body>
</html>